package br.com.simora.crawler;

import javax.inject.Named;

import org.apache.log4j.Logger;

import br.com.simora.musica.Artista;
import br.com.simora.musica.Musica;
import br.com.simora.radio.RadioEnum;

@Named("antena102fm")
public class Antena102FMCrawler extends AbstractCrawler {
	private static Logger logger = Logger.getLogger(Antena102FMCrawler.class);
	private static String URL = "http://www.antena102.com.br/Site/AtualizarPlayer.php";
	
	@Override
	public void recuperaInfo(){
		recuperador.setUrl(URL, "html");
		String itensConteudo = recuperador.getPagina().getConteudo();
		String artistaNome = "";
		String musicaNome = "";
		if(!"".equals(itensConteudo) && null != itensConteudo){
			String[] itens = itensConteudo.split(";");
			if(itens[1]!=null){
				String[] itemFim = itens[1].split("-");
				if(itemFim[0]!=null){
					artistaNome = itemFim[0];
				}
				if(itemFim[0]!=null){
					musicaNome = itemFim[1];
				}
				if(!"".equals(artistaNome) && !"".equals(musicaNome)){
					artista = new Artista();
					artista.setNome(artistaNome.trim());
					musica = new Musica();
					musica.setNome(musicaNome.trim());
				}
			}
		}
		logger.debug(artistaNome + " - " + musicaNome);
	}

	@Override
	public void setRadioNome() {
		this.radioNome = RadioEnum.antena102fm.getNome();
	}

}